package com.bsoft.gol.hcb.service;

import ctd.controller.exception.ControllerException;
import ctd.util.annotation.RpcService;
import hcn.ods.PayTrade;
import hcn.pay.event.PayTradeFinishEvent;

import java.util.Map;

public interface IPayTradeProcessor {

    @RpcService
    Object preProcessTradeSuccess(PayTrade payTrade) throws ControllerException;


    /**
     * 处理交易成功
     *
     * @param payTrade
     * @param response
     * @throws ControllerException
     */
    @RpcService
    void processTradeSuccess(PayTrade payTrade, Object response) throws ControllerException;


    /**
     * 处理交易成功后的处理
     *
     * @param payTrade
     * @throws ControllerException
     */
    @RpcService
    void afterProcessTradeSuccess(PayTrade payTrade) throws ControllerException;

    /**
     * 处理交易失败
     *
     * @param payTrade
     * @throws ControllerException
     */
    @RpcService
    void processTradeFailed(PayTrade payTrade) throws ControllerException;


    /**
     * 是否可以退款
     *
     * @param payTrade
     * @return
     * @throws ControllerException
     */
    @RpcService
    boolean canRefund(PayTrade payTrade) throws ControllerException;

    /**
     * 退款成功
     *
     * @param payTrade
     * @throws ControllerException
     */
    @RpcService
    void processReRefundSuccess(PayTrade payTrade) throws ControllerException;

    /**
     * 退款失败
     *
     * @param payTrade
     * @throws ControllerException
     */
    @RpcService
    void processReRefundFailed(PayTrade payTrade) throws ControllerException;

    /**
     * 创建订单时的额外参数
     *
     * @param payTrade
     * @param params
     * @return
     * @throws ControllerException
     */
    @RpcService
    Map<String, Object> createOrderExtraInfo(PayTrade payTrade, Map<String, Object> params) throws ControllerException;

    /**
     * 整个交易完成（成功，失败）后通知调用接口
     *
     * @param event
     * @throws Exception
     */
    @RpcService
    void notify(PayTradeFinishEvent event) throws ControllerException;
}
